export const validator_username: Function = (rules, value, callback): any => {
  const regUsername = new RegExp("^[0-9A-Za-z]{1,}", "g")
  return regUsername.test(value) ? callback() : callback(new Error('请输入合法的用户名'))
}

export const validator_password: Function = (rules, value, callback): any => {
  const regPassword = new RegExp("^[0-9A-Za-z]{1,}", "g")
  return regPassword.test(value) ? callback() : callback(new Error('请输入合法的密码'))
}

export const RULES: AnyObject = {
  username: [
    { required: true, message: '请输入用户名', trigger: 'blur' },
    { min: 3, message: '用户名须大于3个字符', trigger: 'blur' },
    { validator: validator_username, trigger: 'blur' }
  ],
  password: [
    { required: true, message: '请输入用户密码', trigger: 'blur' },
    { min: 3, message: '用户密码须大于3个字符', trigger: 'blur' },
    { validator: validator_password, trigger: 'blur' }
  ],
}